<? ob_start();?>
<?php
class DB_MySQL {
  private $connection = NULL;
  private $result = NULL;
 
  public function connect($host, $database, $user, $pass) {
    $this->connection = mysql_connect(
      $host,
      $user,
      $pass,
      TRUE
    );
 
    mysql_select_db($database, $this->connection) or die ("ko the tim thay db");
  }
 
  public function disconnect() {
    if (is_resource($this->connection)) {
      mysql_close($this->connection);
    }
  }
 
  public function query($query) {
    if (is_resource($this->connection)) {
      if (is_resource($this->result)) {
        mysql_free_result($this->result) or die("ko the thuc hien truy van");
      }
 
      $this->result = mysql_query(
        $query,
        $this->connection
      );
    }
  }
 
  public function fetchRow() {
    if (is_resource($this->result)) {
      $row = mysql_fetch_assoc($this->result);
 
      if (is_array($row)) {
        return $row;
      } else {
        return FALSE;
      }
    }
  }
      public function num_row(){
        if($this->result){
            $num = mysql_num_rows($this->result);
        }
        return $num; 
    } 
	public function test(){
	 echo "11111111111111";
	}
	
}
?> 